package cc.wanforme.fsync.server.service.impl;

import cc.wanforme.fsync.entity.po.ClientNode;
import cc.wanforme.fsync.server.mapper.ClientNodeMapper;
import cc.wanforme.fsync.server.service.IClientNodeService;
import cc.wanforme.st.server.util.AssertCheck;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class ClientNodeServiceImpl extends ServiceImpl<ClientNodeMapper, ClientNode>
        implements IClientNodeService {

    @Override
    public void saveVo(ClientNode node) {
        AssertCheck.nonNull(node.getName(), "Name is empty.");
        AssertCheck.nonNull(node.getHost(), "Host is empty.");
        AssertCheck.nonNull(node.getPort(), "Port is empty.");
        this.baseMapper.insert(node);
    }

    @Override
    public void updateVo(ClientNode node) {
        AssertCheck.nonNull(node.getId(), "unknown");
        AssertCheck.nonNull(node.getName(), "Name is empty.");
        AssertCheck.nonNull(node.getHost(), "Host is empty.");
        AssertCheck.nonNull(node.getPort(), "Port is empty.");
        this.baseMapper.updateById(node);
    }

}
